﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;

namespace IntelFront.Agent
{
    public class Client
    {
        public Config config;

        public Client()
        {
            this.config = new Config();
        }

        public string getConnectList()
        {
            string func = "/getConnectList";
            WebRequest request = WebRequest.Create(config.url + func);
            request.Method = "GET";
            //request.Headers.Add("PIN", config.PIN);
            request.Headers["OurEDA"] = config.PIN;
            WebResponse response = request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
            string ReturnVal = reader.ReadToEnd();
            reader.Close();
            response.Close();
            return ReturnVal;
        }

        public string getTemperature()
        {
            string func = "/getTemperature";
            WebRequest request = WebRequest.Create(config.url + func);
            request.Method = "GET";
            //request.Headers.Add("PIN", config.PIN);
            request.Headers["OurEDA"] = config.PIN;
            WebResponse response = request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
            string ReturnVal = reader.ReadToEnd();
            reader.Close();
            response.Close();
            return ReturnVal;
        }
    }
}
